]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
endSessionDialog: Small cleanup
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 8 Jul 2022 19:36:07 +0000 (21:36 +0200)
committerMarge Bot <marge-bot@gnome.org>
Mon, 11 Jul 2022 14:14:37 +0000 (14:14 +0000)
Array.prototype.push() returns the new number of elements, so
no need to track the number separately.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2369>

js/ui/endSessionDialog.js

index b0f71f5cff51c4d0fe0905073bce1a35c70f3258..dddfd51f063a9cae03f521760d5b675965276e99 100644 (file)
@@ -647,7 +647,6 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
 
     _loadSessions() {
         this._loginManager.listSessions(result => {
-            let n = 0;
             for (let i = 0; i < result.length; i++) {
                 let [id_, uid_, userName, seat_, sessionPath] = result[i];
                 let proxy = new LogindSession(Gio.DBus.system, 'org.freedesktop.login1', sessionPath);
@@ -675,7 +674,7 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
                     type: proxy.Type,
                     remote: proxy.Remote,
                 };
-                this._sessions.push(session);
+                const nSessions = this._sessions.push(session);
 
                 let userAvatar = new UserWidget.Avatar(session.user, { iconSize: _ITEM_ICON_SIZE });
                 userAvatar.update();
@@ -699,8 +698,7 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
                 this._sessionSection.list.add_child(listItem);
 
                 // limit the number of entries
-                n++;
-                if (n == MAX_USERS_IN_SESSION_DIALOG)
+                if (nSessions === MAX_USERS_IN_SESSION_DIALOG)
                     break;
             }